import request from '@/config/axios'

// 配送 VO
export interface DistributionVO {
  id: string // 主键
  address: string // 客户地址
  care: string // 注意事项
  did: string // 驾驶员id
  driver: string // 司机
  number: string // 车牌号
  phone: string // 客户电话
  status: number // 配送状态：0等待审核、1正在运输、2配送完成
  statusDesc: string // 配送状态描述
  time: Date // 预计送达时间
  urgent: boolean // 是否加急处理true/false
  vid: string // 车辆id
}

// 配送 API
export const DistributionApi = {
  // 查询配送分页
  getDistributionPage: async (params: any) => {
    return await request.get({ url: `/wms/distribution/page`, params })
  },

  // 查询配送详情
  getDistribution: async (id: string) => {
    return await request.get({ url: `/wms/distribution/get?id=` + id })
  },

  // 新增配送
  createDistribution: async (data: DistributionVO) => {
    return await request.post({ url: `/wms/distribution/create`, data })
  },

  // 修改配送
  updateDistribution: async (data: DistributionVO) => {
    return await request.put({ url: `/wms/distribution/update`, data })
  },

  // 删除配送
  deleteDistribution: async (id: string) => {
    return await request.delete({ url: `/wms/distribution/delete?id=` + id })
  },

  // 导出配送 Excel
  exportDistribution: async (params) => {
    return await request.download({ url: `/wms/distribution/export-excel`, params })
  },

  // 配送审核确认
  confirmAudit: async (id: string) => {
    return await request.put({ url: `/wms/distribution/confirm-audit/` + id })
  },

  // 配送完成确认
  confirmOk: async (id: string) => {
    return await request.put({ url: `/wms/distribution/confirm-ok/` + id })
  },
}
